<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%@taglib uri="/mytags" prefix="m"%>
<%@ taglib prefix='fmt' uri="http://java.sun.com/jsp/jstl/fmt" %>

<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + ":" + request.getServerPort()
            + path + "/front/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
    <title>课程学习</title>

    <s:include value="css_script_common.jsp"></s:include>
    <s:include value="popup_teacherdetail.jsp"></s:include>
    <!------------trollBox引用---->
    <script type="text/javascript" src="js/coursestudentapply.js"></script>

    <script type="text/javascript">
        function iFrameHeight() {
            var ifm= document.getElementById("classIntroduce");
            var subWeb = document.frames ? document.frames["classIntroduce"].document : ifm.contentDocument;
            if(ifm != null && subWeb != null) {
                ifm.setAttribute("height",subWeb.body.scrollHeight);
            }
        }
        function saveClassComment(){
            var comment = $.trim($("#class_comment_area").val());
            if(!comment && comment == ''){
                alert("请填写评价内容");
                return;
            }
            if($("#default input").val()){
                $("#comment_score").val($("#default input").val());
            }else{
                $("#comment_score").val(0);
            }

            $("#class_comment_classpk").val($("#class_pk").val());

            $("#class_comment_form").submit();
        }

        function showMore(){
            $.ajax({
                url: "courseleaning_showClassComments?organization.pk="+$("#organization_pk").val()+"&classComment.classpk.pk="+$("#class_pk").val()+"&classlist.pk="+$("#class_pk").val()+"&classCommentCount="+$("#class_comment_count").val(),
                type:"post",
                dataType:"json",
                success:function(data){
                    $("#show_more_class_comments").html("");
                    $("#see_more").html("");

                    $.each(data.classCommentList, function(i, value){
                        var replayMsg = value.replyMessage;
                        if(!replayMsg){
                            replayMsg = "";
                        }

                        var headPic = value.headPic;
                        if(!headPic){
                            headPic = "images/avatar/avatar_male_samll.jpg";
                        }

                        var nickName = value.nickName;
                        var isAnonymous = value.isAnonymous;
                        if(isAnonymous == 'y'){
                            nickName = "匿名";
                        }

                        var score = value.score;
                        var _score = "";
                        if(score && score == 1){
                            _score = "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" /> ";
                        }
                        if(score && score == 2){
                            _score = "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" /> ";
                        }
                        if(score && score == 3){
                            _score = "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" /> ";
                        }
                        if(score && score == 4){
                            _score = "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" /> ";
                        }
                        if(score && score == 5){
                            _score = "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_y.png\" />"+
                                    "<img src=\"images/stars/xx_y.png\" /> ";
                        }
                        if(!score){
                            _score = "<img src=\"images/stars/xx_b.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" />"+
                                    "<img src=\"images/stars/xx_b.png\" /> ";
                        }

                        var _tr = $("<li class='by_user'>"+
                                        "<a title''>"+
                                        "<img width='60px' height='60px' src='"+headPic+"'/>"+
                                        "<div class='clear'></div>"+
                                        "<span class='name'>"+
                                        "<strong>"
                                        +nickName+
                                        "</strong>"+
                                        "</span>"+
                                        "</a>"+
                                        "<div class='messageArea'>"+
                                        "<span class='aro'></span>"+
                                        "<div class='infoRow'>"
                                        +_score+
                                        "<span class='time'>"
                                        +value.createTimeForAjax+
                                        "</span>"+
                                        "<div class='clear'></div>"+
                                        "</div>"
                                        +value.commentMessage+
                                        "</div>"+
                                        "<div class='messageArea2'>"+
                                        "<div class='infoRow'>"
                                        +"回复:"+
                                        "<span class='time'>"
                                        +value.replyTimeForAjax+
                                        "</span>"+
                                        "<div class='clear'></div>"+
                                        "</div>"
                                        +replayMsg+
                                        "</div>"+
                                        "</li>"
                        );

                        $("#show_more_class_comments").append(_tr);

                    });

                    $("#class_comment_count").val(data.classCommentCount);

                    if(data.showMoreClassComment == true){
                        var more_link = $("<a href='javascript:showMore()' class='clickmore whitebg body'>点击查看更多</a>");
                        $("#see_more").append(more_link);
                    }
                }
            });
        }

    </script>

</head>

<body>
<!-- 顶部开始 -->
<s:include value="./frame/head.jsp"></s:include>
<!-- 顶部结束 -->

<!-- 广告开始-->
<s:include value="./frame/ad.jsp"></s:include>
<!-- 广告结束-->
<s:set name="menuname" value="'courselearning'"></s:set>
<s:include value="./frame/menu.jsp"></s:include>

<!-- 内容开始 -->
<div id="content" class="mauto"><!-- 主要内容开始 -->
<div class="wrapper">
<div class="fluid">
<div class="widget grid3">
    <s:include value="org_summary.jsp"></s:include>
    <s:include value="last_informations.jsp"></s:include>
</div>
<div class="widget grid9">
<div class="whead">
    <h5>&nbsp;</h5>
    <div class="clear"></div>
</div>
<div class="classline">
    <div class="classblock whitebg ml0">
        <div class="body bGrayB">
            <h5>${classlist.name }<s:if test="organizationCoupon!=null"><span class="coupons_icon t39"></span></s:if></h5>
        </div>
        <div class="body grid6 ml0">
            <p>课程类型：<s:if test="classlist.studymothed=='online'">在线学习</s:if> <s:elseif
                    test="classlist.studymothed=='offline'">线下课程</s:elseif> <s:else>无</s:else></p>
            <p>授课地点：${classAdress }</p>
            <p>开课日期：<s:if test="classlist.starttype == 1"><m:integerDate intstrvalue='%{classlist.startmark}' format='yyyy-MM-dd'/></s:if><s:else>随到随学</s:else></p>
            <p>课时：${classlist.hour }课时</p>
            <p>主讲教师：<s:if test="orgTeacher!=null">
                <a href="javascript:shouteacherdetail(${orgTeacher.pk})">${orgTeacher.name
                        }</a>
            </s:if><s:else>无</s:else></p>
        </div>
        <div class="body grid6">
            <p class="price">评价:<s:include value="score_img.jsp">
                <s:param name="avgscore">${classlist.avgscore}</s:param>
            </s:include></p>
            <div class="price">
                <s:if test="classlist.price<0.02">
                    <p>原价：<span class="oprice" style="text-decoration: none">面议</span></p>
                </s:if> <s:else>
                <p>原价：￥<span class="oprice"><m:doubleFormat
                        value="%{classlist.price}"></m:doubleFormat></span></p>
            </s:else>
                <s:if test="classlist.favourprice<0.01">
                    <p>e学价：<span class="cprice" style="text-decoration:none">面议</span></p>
                </s:if> <s:else>
                <p>e学价：￥<span class="cprice" style="text-decoration:none"><m:doubleFormat
                        value="%{classlist.favourprice}"></m:doubleFormat></span></p>
            </s:else>
                </p>

                <s:if test="guiBusinessClass.state=='open'">
                    <s:if test="detailpaytype=='all'">
                        <p>购买价：￥<span class="cprice"><fmt:formatNumber value="${guiBusinessClass.price}" pattern="#0.00" /></span>
                        </p>
                    </s:if><s:else>
                    <p>订金：￥<span class="cprice">${guiBusinessClass.price}</span>
                    </p>
                    <p><span class="warning warning-important">请在报到后支付剩余价款</span></p>
                </s:else>

                </s:if>

            </div>
        </div>
        <div class="clear"></div>
        <div class="body bGray ml0">
            <s:if test="guiBusinessClass.state=='open'"></s:if>
            <s:else>
                <a
                        class="buttonS bBlue mr15" href="javascript:applySignUp(${organization.pk},${classlist.pk },'${classlist.name }')">在线报名</a>
            </s:else>
            <s:if
                    test="organizationCoupon!=null">
                <a id="" class="buttonS bBlue mr15"
                   href="coupon_detail?organization.pk=${organization.pk}&couponPk=${organizationCoupon.pk }">优惠券</a>
            </s:if>
            <a class="buttonS bBlue mt10"
               href="consultMessage_openConsultMsg?organization.pk=${organization.pk}&classPk=${classlist.pk }&className=${classlist.name }">在线咨询</a>
            <s:if test="guiBusinessClass.state=='open'">
                <a class="buttonS bOrange ml10"
                   href="javascript:buyClassOrder(${organization.pk},${classlist.pk },'${classlist.name }')">购买</a>
            </s:if>
            <div class="clear"></div>
        </div>
    </div>
    <div class="clear"></div>
</div>

<div class="whead blueline">
    <h5>课程简介</h5>

    <div class="clear"></div>
</div>
<div class="classline">
    <iframe id='classIntroduce' width='100%' onLoad="iFrameHeight()" scrolling="no" border="0" frameborder=”no” allowtransparency="true" style="background-color:transparent"
            src='./admin/classlistmanage_loadingClassIntro?classlist.pk=${classlist.pk}' >
    </iframe>
    <div class="clear"></div>
</div>
<a name="comment" id="comment" ></a>
<div class="whead blueline">
    <h5>课程评价</h5>
    <span class="floatR">5星 (${commentstart[4]})  4星(${commentstart[3]}) 3星(${commentstart[2]}) 2星(${commentstart[1]}) 1星(${commentstart[0]}) </span>
    <div class="clear"></div>
</div>
<s:if test="#session.loginUser == null">
    <p>
        如您为已
        <a href="reg_login.jsp">注册</a>
        用户，请先
        <a href="reg_login.jsp">登录</a>
    </p>
</s:if>
<div class="classline">
    <div class="body whitebg">
        <form id="class_comment_form" action="courseleaning_saveClassComment?organization.pk=${organization.pk}" method="post" enctype="multipart/form-data">
            <s:hidden id="organization_pk" name="organization.pk"></s:hidden>
            <s:hidden id="class_comment_count" name="classCommentCount"></s:hidden>
            <s:hidden id="class_pk" name="classlist.pk"></s:hidden>
            <s:hidden id="class_comment_classpk" name="classComment.classpk.pk"></s:hidden>
            <s:if test="#session.loginUser != null">
                <div class="formRow">我要评价：
                    <div id="default" class="displayin"></div>
                    <s:hidden id="comment_score" name="classComment.score"></s:hidden>
                </div>

                <div class="formRow">
                    <textarea id="class_comment_area" name="classComment.commentMessage" cols="" rows="8" ></textarea>
                </div>

                <div class="formRow">
                    <label>匿名评价：
                        <input name="classComment.isAnonymous" type="radio" id="RadioGroup1_0" value="y" checked="checked" /> 是
                    </label>
                    <label class="ml10">
                        <input type="radio" name="classComment.isAnonymous" value="n" id="RadioGroup1_1" /> 否
                    </label>
                    <a class="buttonS bBlue floatR" href="javascript:saveClassComment()">提交</a>
                    <div class="clear"></div>
                </div>
            </s:if>
        </form>
        <ul id="show_more_class_comments" class="messagesOne">
            <s:iterator value="classCommentList" status="comments">
                <li class="by_user">
                    <a href="#" title="">
                        <s:if test="headPic == null || isAnonymous+'es' == 'yes' ">
                            <img src="images/avatar/avatar_male_samll.jpg" alt="" />
                        </s:if>
                        <s:else>
                            <img width="60px" height="60px" src="<s:property value="headPic" />" alt="" />
                        </s:else>
                        <div style="clear:both;"></div>
													<span class="name">
														<strong>
                                                            <s:if test="isAnonymous+'es' == 'yes' ">
                                                                匿名
                                                            </s:if>
                                                            <s:else>
                                                                <s:property value="nickName" />
                                                            </s:else>
                                                        </strong>
													</span>
                    </a>

                    <div class="messageArea">
                        <span class="aro"></span>
                        <div class="infoRow">
                            <s:include value="score_img.jsp">
                                <s:param name="avgscore">${score}</s:param>
                            </s:include>
														<span class="time">
															<m:integerDate value="%{createTime}" format="yyyy-MM-dd"/>
														</span>

                            <div class="clear"></div>
                        </div>
                            ${commentMessage }
                    </div>

                    <s:if test="replyMessage != null" >
                        <div class="messageArea2">
                            <div class="infoRow">
                                回复：
							                            <span class="time">
							                            	<m:integerDate value="%{replytime}" format="yyyy-MM-dd"/>
							                            </span>

                                <div class="clear"></div>
                            </div>
                                ${replyMessage }
                        </div>
                    </s:if>

                    <div class="clear"></div>

                </li>
            </s:iterator>
        </ul>

        <!-- Pagination -->
        <s:if test="showMoreClassComment" >
            <div id="see_more" class="pagination">
                <a href="javascript:showMore()" class="clickmore whitebg body">点击查看更多</a>
            </div>
        </s:if>




    </div>

    <div class="clear"></div>

</div>


</div>
</div>
</div>
</div>

<!-- 底部开始 -->
<s:include value="popup_regnewstudent.jsp"></s:include>
<s:include value="popup_showapplyresult.jsp"></s:include>
<s:include value="./frame/foot.jsp"></s:include>
<!-- 底部结束 -->

</body>
</html>
